<? if (!defined("BASEPATH")) exit("No direct script access allowed");

echo	"<h2>".$title."</h2>";

echo	"<h3>".$this->lang->line("WHAT_ARE_YOU_LOOKING_FOR")."</h3>";

$progTypes = array(
	"study_abroad" => $this->lang->line("STUDY_ABROAD_PROGRAMMES"),
	"scholarships" => strtolower($this->lang->line("SCHOLARSHIPS")),
	"internships" => $this->lang->line("INTERNSHIPS"),
	"work_study" => $this->lang->line("WORKSTUDY_PROGRAMMES"),
);

echo	form_open("advanced_search", array("id" => "frmAdvancedSearch"));
echo	"<div class=\"box gray\">";
echo	"<table cellspacing=\"0\" style=\"margin-left: 20px;\">";

foreach($progTypes as $type => $name) {
	echo	"<tr>";
	echo 		"<td class=\"vm\">".form_radio(array("name" => "progTypes", "id" => "pt_".$type, "value" => "pt_".$type) + (($this->input->post("progTypes") === "pt_".$type)?(array("checked" => TRUE)):(array())))."</td>";
	echo 		"<td class=\"vm\">".form_label($name, "pt_".$type)."</td>";
}
echo		"</tr>";
echo	"</table>";
echo	"</div>";

echo	"<div id=\"findBy\">";
if(isset($find_by)) echo $find_by;
echo	"</div>";

if(isset($getMajor)) {
	echo	"<br class=\"cb\" /><br class=\"cb\" />";
	if(count($getMajor)) {
		echo	"<h3><p class=\"fl\">".$this->lang->line("NUMBER_OF_COURSES").": ".$getMajorCount."</fl><p class=\"fr\">[".($start+1)." - ".min($getMajorCount, $start+$this->config->item("searchPageSize"))."]<p><br class=\"cb\" /></h3>";
	} else {
		echo	"<div class=\"alert_error\">".$this->lang->line("NO_RESULTS_FOUND_TRY_ANOTHER_SEARCH")."</div>";
	}

	$jj = $start + 1;
	foreach($getMajor as $ii => $maj) {
		echo	"<div class=\"box ".(($ii%2)?("gray"):(""))."\">";
		echo		"<h3>".anchor("institutes/".$maj["insUrlName"]."/".$maj["majUrlName"], $maj["majName"])." <p class=\"searchresult color".(($ii%2)?("white"):("gray"))." fr\">".$jj.".</p></h3><br class=\"cb\" />";
		echo		"<p class=\"fl\">".anchor("institutes/".$maj["insUrlName"], $maj["insName"])."</p><p class=\"fr\">".anchor($maj["conUrlName"]."/".$maj["couUrlName"]."/".$maj["cityUrlName"], $maj["cityName"])." (".anchor($maj["conUrlName"]."/".$maj["couUrlName"], $maj["couName"]).")</p>";
		echo		"<br class=\"cb\" />";
		if($maj["e2cDescription"]) {
			echo		"<br class=\"cb\" />";
			echo		auto_link($maj["e2cDescription"]);
			echo		"<br class=\"cb\" />";
		}
		echo		"<p class=\"fr\">".anchor("institutes/".$maj["insUrlName"]."/".$maj["majUrlName"], $this->lang->line("VIEW_DETAIL"))."</p>";
		echo		"<br class=\"cb\" />";
		echo	"</div>";
		$jj++;
	}

	$config["base_url"] = base_url()."advanced_search";
	$config["total_rows"] = $getMajorCount;
	$config["uri_segment"] = 2;
	$config["num_links"] = 10;
	$config["per_page"] = $this->config->item("searchPageSize");

	$this->pagination->initialize($config);

	echo	"<div class=\"fr\">";
	echo		$this->pagination->create_links();
	echo	"</div>";
	echo	"<br class=\"cb\" />";
}

echo	form_close();
?>
<script type="text/javascript">
	$(document).ready(function() {
		<?=((!isset($_POST) or empty($_POST))?("\$('#mainmenu').mouseover();"):("\$('html,body').scrollTop(\$('#advancedSearchButton').offset().top-50);"))?>
		$('input[type=radio]').live('change', function() { 
			$.ajax({
				url: '<?=base_url()?>advanced_search/' + $('input:radio[name=progTypes]:checked').val(),
				type: 'get',
				async: false,
				beforeSend: function() {
					$('#findBy').html('<?=Common::ajaxWaitMessage()?>');
				},
				success: function(response) {
					$('#findBy').html(response);
					accordion();
				}
			});
		});
	})
</script>
